package bb.lanxing.util.map;

import android.annotation.SuppressLint;

import com.baidu.mapapi.model.LatLng;

import bb.lanxing.App;
import bb.lanxing.R;

public class SphericalUtil {
    @SuppressLint("StringFormatMatches")
    public static String formatDistance(double d) {
        return d < 1000.0d ? App.getContext().getString(R.string.str_fm_unit_m_cn, (int) d) : App.getContext().getString(R.string.str_fm_unit_km_cn, (int) ((d / 1000.0d) + 0.5d));
    }

    public static double computeDistanceBetween(LatLng latLng, LatLng latLng2) {
        return distanceRadians(Math.toRadians(latLng.latitude), Math.toRadians(latLng.longitude),
                Math.toRadians(latLng2.latitude), Math.toRadians(latLng2.longitude)) * 6371009.0d;
    }

    private static double distanceRadians(double d, double d2, double d3, double d4) {
        return MathUtil.arcHav(MathUtil.havDistance(d, d3, d2 - d4));
    }
}